const YHSearch = [
  {
    name: 'components',
    type: 'SearchComponentProps[]',
    value: [
      {
        component: 'input',
        label: '购卡单号',
        name: 'orderId',
        config: {
          placeholder: '请输入购卡单号',
        },
      },
      {
        component: 'input',
        label: '门店编码',
        name: 'shopId',
        config: {
          placeholder: '请输入门店编码',
        },
      },
      {
        component: 'input',
        label: '手机号',
        name: 'phone',
        config: {
          placeholder: '请输入手机号',
        },
      },
      {
        component: 'select',
        label: '订单状态',
        name: 'orderStatus',
        config: {
          allowClear: true,
          placeholder: '请选择',
          options: [
            // { label: '全部', value: '' },
            { label: '待支付', value: 0 },
            { label: '已支付', value: 1 },
          ],
        },
      },
      {
        component: 'select',
        label: '交易平台',
        name: 'tradePlatform',
        config: {
          allowClear: true,
          placeholder: '请选择',
          options: [
            // { label: '全部', value: '' },
            { label: 'APP', value: 1 },
            { label: '微信小程序', value: 2 },
          ],
        },
      },
      {
        component: 'date-picker',
        label: '购买时间',
        name: 'time',
        config: {
          // showTime: true,
          // placeholder: '开始日期',
        },
      },
    ],
  },
  {
    name: 'onSubmit',
    value: () => {},
  },
  {
    name: 'onReset',
    value: () => {},
  },
];

const YHForms = [
  {
    name: 'components',
    type: 'FormsComponentsProps',
    value: {
      items: [
        {
          title: '',
          button: {
            textAlign: 'left',
            list: [
              {
                action: 'submit',
                text: '提交',
                type: 'primary',
                onClick: (e) => {
                  store.submitData(e);
                },
              },
              {
                action: 'cancel',
                text: '取消',
                onClick: (e) => {
                  console.log(e);
                },
              },
            ],
          },
          components: [
            {
              component: 'input',
              name: 'username',
              label: '用户名',
              config: {},
            },
            {
              component: 'input.password',
              name: 'password',
              label: '密码',
              config: {},
            },
            {
              component: 'select',
              label: '下拉框',
              name: 'select',
              config: {
                placeholder: '请输入下拉框',
                options: [
                  { key: 'op1', value: 'Jack', label: 'Jack1' },
                  { key: 'op2', value: 'Lucy', label: 'Lucy1' },
                ],
              },
            },
            {
              component: 'date-picker',
              label: '开始日期',
              name: 'date1',
              config: { placeholder: '请选择日期', format: 'YYYY/MM/DD' },
            },
            {
              component: 'radio',
              label: '单选框',
              name: 'radio1',
              config: {
                options: [
                  { label: 'A', value: 'A' },
                  { label: 'B', value: 'B' },
                  { label: 'C', value: 'C' },
                ],
              },
            },
          ],
        },
      ],
    },
  },
  {
    name: 'styleControl',
    value: { formItem: { labelCol: { span: 4 }, wrapperCol: { span: 8 } } },
  },
];

const YHTable = [
  {
    _init: () => {
      // _init在将下面的数据插入到组件之前，要执行的函数，可用来引入其他的组件等
      const insertString = `
      const TABLE_ICON_MAP = {
        0: {
          name: '失败',
          value: '#FF505F',
        },
        1: {
          name: '成功',
          value: '#52C41A',
        },
        2: {
          name: '等待',
          value: '#FFAF25',
        }
      };

      const TABLE_BTN_CONFIG = {
        del: {
          title: '删除',
          popconfirm: {
            title: '删除此内容?',
            okText: '删除',
            onConfirm: () => {
              alert('删除成功')
            },
          },
        },
        view: {
          title: '查看',
          action: () => {
            
          },
        },
        edit: {
          title: '编辑',
          action: () => {
          },
        },
      };

      const TABLE_ACTION_STATUS_CONFIG = {
        0: ['del', 'view'],
        1: ['del', 'edit'],
        2: ['edit', 'del', 'view'],
      };

      const TableActions = TableAction(TABLE_BTN_CONFIG, TABLE_ACTION_STATUS_CONFIG);
      const StatusIcon = TableStatus(TABLE_ICON_MAP);`;
      return { insertString };
    },
    name: 'columns',
    value: Array(5)
      .fill(1)
      .map((_, index) => ({
        title: `title${index}`,
        dataIndex: `title${index}`,
        key: `title${index}`,
        ...(index === 3
          ? {
              render: (v) => '<StatusIcon status={v%3} />',
            }
          : {}),
        ...(index === 4
          ? {
              render: (v, row) => ' <TableActions status={v%3} data={row} />',
            }
          : {}),
      })),
  },
];

const YHFormsStep = [
  {
    name: 'components',
    type: 'FormsComponentsProps',
    value: {
      type: 'steps',
      steps: {
        step: [{ title: '步骤01' }, { title: '步骤02' }, { title: '步骤03' }],
      },
      items: [
        {
          title: '分组01',
          button: {
            textAlign: 'right',
            list: [
              // 考虑 分步 和 分组表单 设计成数组
              {
                action: 'next', // 用户行为  next 分步form 才会用到， 用于更新 步骤 step + 1
                text: '下一步',
                type: 'primary',
                onClick: () => {
                  console.log('form next');
                },
              },
            ],
          },
          components: [
            {
              component: 'input',
              name: 'username',
              label: 'username',
            },
            {
              component: 'input.password',
              name: 'password',
              label: 'password',
            },
          ],
        },
        {
          title: '分组02',
          button: {
            textAlign: 'right',
            list: [
              // 考虑 分步 和 分组表单 设计成数组
              {
                action: 'pre', // 用户行为  pre 分步form 才会用到， 用于更新 步骤 step - 1
                text: '上一步',
                step: 2,
                onClick: () => {
                  console.log('form pre');
                },
              },
              {
                action: 'next',
                text: '下一步',
                type: 'primary',
                onClick: () => {
                  console.log('form next');
                },
              },
            ],
          },
          components: [
            {
              component: 'select',
              name: 'select2',
              label: '下拉框2',
              config: {
                options: [
                  {
                    value: '1',
                    label: '下拉框1',
                  },
                  {
                    value: '2',
                    label: '下拉框2',
                  },
                ],
              },
            },
            {
              component: 'range-picker',
              label: '时间区间',
              name: 'range2',
              config: {
                placeholder: ['请选择开始日期', '请选择结束日期'],
              },
            },
          ],
        },
        {
          title: '分组03',
          button: {
            textAlign: 'right',
            list: [
              // 考虑 分步 和 分组表单 设计成数组
              {
                action: 'pre', // 用户行为  pre 分步form 才会用到， 用于更新 步骤 step - 1
                text: '上一步',
                step: 2,
                onClick: () => {
                  console.log('form pre');
                },
              },
              {
                action: 'submit', // 用户行为 提交行为
                text: '提交',
                type: 'primary',
                onClick: (d) => {
                  store.submitData(d);
                },
              },
            ],
          },
          components: [
            {
              component: 'input',
              name: 'content',
              label: '内容',
              config: {
                placeholder: '请随便输入',
              },
            },
          ],
        },
      ],
    },
  },
];

// // 用于处理
// const otherMock=[

// ]

// 模板中需要替换的名字
const templateAlias = {
  YHFormsStep: 'YHForms',
};
const map = {
  YHSearch,
  YHForms,
  YHTable,
  YHFormsStep,
};

module.exports = {
  constantsMap: map,
  templateAlias,
};

// console.log(JSON.stringify(YHSearch_components()));
